
// debugger
// 通过复制word文档得试题，正则匹配，得出正确答案+题目对应的章节
var initCurData = window.initCurData = function (testQuestion) {
  const regSecialSymbols = /(\n|\r|\r\n|↵)/g // 正则：换行符等
  // debugger
  var testList = testQuestion.split('==-=--=')
  // 剔除数组的空元素
  testList = testList.filter(function (s) {
    return s && s.trim()
  })

  // debugger
  window.rightAnswerA = '' // 正确答案+对应章节
  window.rigthAnswer = '' // 正确答案

  // debugger
  testList.forEach(function (o, i) {
    const arr1 = o.split('|*|*|')
    const answer1 = arr1[1].split('||-||') // 获取答案+题目对应的章节
    var charter = answer1[1] // 题目对应的章节

    if (charter.match(regSecialSymbols)) {
      const charter1 = charter.split(regSecialSymbols)
      charter = charter1[0]
      // debugger
    }

    const rightAnswer1 = answer1[0].split(regSecialSymbols) // ["正确答案：B", "↵", "    解析：PMBOK(6)P244- "]
    const rightAnswer2 = rightAnswer1[0].split(/[:|：]/g) // ["正确答案", "B"]
    const right = rightAnswer2[1] // 正确答案 B

    const sysBolReg = /,|，/g
    const hasSysbol = right.match(sysBolReg)
    var right1 = right
    if (hasSysbol) {
      // right = '(' + right.replace(sysBolReg, '') + ')'
      right1 = '(' + right.replace(sysBolReg, '') + ')'
      // debugger
    }

    window.rightAnswerA += right + ' ' + charter + ',' // 正确答案+对应章节
    window.rigthAnswer += right1 // 正确答案
  })

  // console.log(' window.rightAnswerA： ', window.rightAnswerA)
  // console.log(' window.rigthAnswer： ', window.rigthAnswer)
}

